import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-12-20
 * Time: 21:26
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //多开辟空间，防止数组越界
        int[][] arr = new int[510][510];
        int[][] dp = new int[510][510];
        //将arr数组元素读入，由于dp存放的是背包中的元素，
        //即使arr数组没有全部填充也不影响（因为遍历的时候只遍历有效的元素）
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= i; ++j) {
                arr[i][j] = scan.nextInt();
            }
        }
        //将dp背包初始化（存入int的最小元素）
        for (int i = 0; i < dp.length; ++i) {
            //调用fill方法填充
            /**
             *     public static void fill(int[] a, int val) {
             *         for (int i = 0, len = a.length; i < len; i++)
             *             a[i] = val;
             *     }
             */
            Arrays.fill(dp[i], Integer.MIN_VALUE);
        }
        //遍历填充
//        for (int i = 0; i < dp.length; ++i) {
//            for (int j = 0; j < dp[i].length; ++j) {
//                dp[i][j] = Integer.MIN_VALUE;
//            }
//        }

        //记录左拐和优化的数
        int[][] count = new int[510][510];
        //初始化第一个数组
        dp[1][1] = arr[1][1];
        for (int i = 2; i <= n; ++i) {
            for (int j = 1; j <= i; ++j) {
                if (dp[i-1][j-1] > dp[i-1][j]) {
                    dp[i][j] = dp[i-1][j-1] + arr[i][j];
                    //左拐+1
                    count[i][j] = 1 + count[i-1][j-1];
                }else {
                    dp[i][j] = dp[i-1][j] + arr[i][j];
                    //右拐-1
                    count[i][j] = count[i-1][j] - 1;
                }
            }
        }
        //遍历最后一行，找到最大的数
        int ans = Integer.MIN_VALUE;
        for (int i = 1; i <= n; ++i) {
            //左拐和右拐的次数相差不能大于1
            if ((count[n][i] >= -1) && (count[n][i] <= 1)){
                ans = Math.max(ans, dp[n][i]);
            }
        }
        System.out.println(ans);

        scan.close();
    }
}
